package com.manage.system.job;

import com.manage.system.context.DataSourceContextHolder;
import com.manage.system.dao.SeeDataBaseDao;
import com.manage.system.entity.BaseCheckSessionEntity;
import com.manage.system.entity.RcsSeePushEntity;
import com.manage.system.entity.Student;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author liuzhao
 * @Date 2024/1/20 19:03
 * @Content
 * @Version 1.0
 */
@Slf4j
@Component
public class DynamicSourceJob {

    @Autowired
    SeeDataBaseDao seeDataBaseDao;

    @Scheduled(cron = "0 0 0 * * ?")
    public void rcsJobTest() {
        DataSourceContextHolder.setDataSource("rcs");
        RcsSeePushEntity rcsSeePushEntity = seeDataBaseDao.getRcsSeePushData();
        DataSourceContextHolder.clearDataSource();
        log.info("RCS数据源查询推送数据：{}", rcsSeePushEntity);
    }

    @Scheduled(cron = "0 0 0 * * ?")
    public void seeJobTest() {
        DataSourceContextHolder.setDataSource("see");
        BaseCheckSessionEntity baseCheckSessionData = seeDataBaseDao.getBaseCheckSessionData();
        DataSourceContextHolder.clearDataSource();
        log.info("SEE数据源查询质检数据：{}", baseCheckSessionData);
    }

    @Scheduled(cron = "0 0 0 * * ?")
    public void mountainJobTest() {
//        DataSourceContextHolder.setDataSource("see");
        Student student = seeDataBaseDao.getStudentData();
//        DataSourceContextHolder.clearDataSource();
        log.info("MOUNTAIN数据源查询学生数据：{}", student);
    }
}
